# simpleURrobotGUI

simple Universal Robots UR3e PyQt5 GUI with camera preview, with gamepad/joystick (hidapi, without pygame) controling TCP mode, and joints mode movements - 3 axis for TCP mode and 6 axis for joints movement - switching between modes using X (TCP mode) and Y (joints mode) buttons on the gamepad. <br> 
The gamepad/joystick controls are made, using pyjoystick module (https://pypi.org/project/pyjoystick/), without pygame. <br> 
The gripper operations are using https://sdurobotics.gitlab.io/ur_rtde/_static/robotiq_gripper.py <br> 


This program is using ur_rtde module ( https://sdurobotics.gitlab.io/ur_rtde/index.html ): <br>
pip3 install ur_rtde <br>

List of imports:

from PyQt5 import QtCore, QtGui, QtWidgets <br>
from PyQt5.QtWidgets import QDialog <br>
from PyQt5.QtCore import QTimer, QTime <br>
from simpleRobotGUI_v1_ui import Ui_simpleRobotGUI <br>
<br>
import rtde_control <br>
import rtde_receive <br>
import robotiq_gripper <br>
import time <br>
import traceback <br>
<br>
import pyjoystick <br>
from pyjoystick.sdl2 import Key, Joystick, run_event_loop <br>
from qt_thread_updater import ThreadUpdater <br>
<br>
import cv2 <br>
import numpy as np <br>
from imageio.v3 import imread <br>
import csv <br>
import sys <br>
<br>
To run: <br>
python3 simpleRobotGUI_v1.py <br>
<br>

The GUI is handling keyPressEvent to emulate the broken Jog functionality.
To drive the robot in real time from the keyboard - first click on INIT CONTROL, then use any of jogging keys - A, S, W, D, X, to move the respectively X+, X-, Y+, Y-, Z+, Z-, TCP axis. 
In addition you can use K, L, O, P, N, M, to jog first 3 joints axis in positive or negative directions. <br>
To control the next 3 joints axis use keys: 0, 9, U, I, H, J, V, B. 

<br>
<p> 
    def keyPressEvent(arg, e): 
        ...
		elif e.key() == 65: 
			# print("a") <br>
			arg.joint_speed = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 
			acceleration = 0.5 
			dt = 1.0/500 
			t_start = arg.rtde_c.initPeriod() 
			print(t_start) 
			arg.joint_speed[0] = +0.025 
			arg.rtde_c.speedL(arg.joint_speed, acceleration, dt) 
			arg.rtde_c.waitPeriod(t_start) 
        ...
        elif e.key() == 81: 
			# print("q") 
			arg.rtde_c.speedStop(acceleration) 
			arg.joint_speed = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 
</p> 
<br>

![Screenshot of the simpleURrobotGUI](https://notabug.org/klazarski/simpleURrobotGUI/src/master/images/simpleURrobotGUI_2023-08-08.png)

<br>